<template>
  <div class="edit-dialog-container">
    <el-dialog :title="state.dialog.title" v-model="state.dialog.isShowDialog" width="769px" destroy-on-close>
      <el-form ref="dialogFormRef" :model="state.content" size="default" label-width="90px">
        <el-row :gutter="35">
          <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
            <el-form-item prop="name" label="会议名称">
              <el-input v-model="state.content.name" :disabled="state.dialog.type === 1" placeholder="请输入会议名称"
                clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
            <el-form-item prop="days" label="选择日期">
              <el-date-picker v-model="state.content.days" type="datetimerange" range-separator="To"
                start-placeholder="Start date" end-placeholder="End date" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="35">
          <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
            <el-form-item prop="name" label="会议名称">
              <el-checkbox v-model="checked1" disabled>是否通知参会人员</el-checkbox>
              <el-checkbox v-model="checked2"></el-checkbox>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="onSubmit" type="success" size="default">确认</el-button>
          <el-button @click="onCancel" size="default">取消</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref } from 'vue';
import { ElMessage } from 'element-plus';

const emit = defineEmits(['refresh']);

// 定义变量内容
const dialogFormRef = ref();

const useContent = () => {
  return {
    days: '', // 账户名称
    name: '', // 用户姓名
  }
}

const state = reactive({
  content: {} as any,
  dialog: {
    isShowDialog: false,
    type: 0,
    title: '新增',
  },
});

// 打开弹窗
const openDialog = async (code?: string) => {
  state.dialog.isShowDialog = true
  if (code) {
    state.dialog.title = '编辑'
    state.dialog.type = 1
  } else {
    state.dialog.type = 0
    state.content = useContent()
  }
};
// 关闭弹窗
const closeDialog = () => {
  state.dialog.isShowDialog = false;
  state.content = useContent()
  emit('refresh');
};
// 取消
const onCancel = () => {
  closeDialog();
};

// 提交
const onSubmit = () => {
  if (state.dialog.type === 1) {

  } else {

  }
};

defineExpose({
  openDialog,
});
</script>


<style scoped lang="scss">
:deep(.el-dialog__header) {
  margin: 0;
  border-bottom: 1px dashed rgba(0, 0, 0, .2);
}

:deep(.el-dialog__footer) {
  border-top: 1px dashed rgba(0, 0, 0, .2);
}
</style>